package com.bana.fvs.protocol;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 * 吸合继电器某一路
 */
public class SetRelayOpen {

    public int getId()
    {
        return 0x12;
    }
    
    public byte[] toBuffer(int data) throws IOException {

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(baos);
        dos.writeByte(0x55);
        dos.writeByte(0x01);
        dos.writeByte(getId());
        dos.writeByte(0x00);
        dos.writeByte(0x00);
        dos.writeByte(0x00);
        dos.writeByte(data);
        dos.writeByte(0x55+0x01+getId()+data);
        byte[] buffer= baos.toByteArray();
        dos.close();
        baos.close();
        return buffer;
    }

}
